<template>
  <a-modal
    title="列表"
    :width="350"
    :visible="visible"
    :confirmLoading="loading"
    @ok="() => {$emit('ok')} "
    @cancel=" () => {$emit('cancel')}"
    :footer="null"
  >
    <a-spin :spinning="loading">
      <s-table ref="table" size="default" rowKey="id" :columns="columns" :data="loadData" showPagination="auto">
        <span slot="name" slot-scope="text, scope">
          <span class="jumpName" @click="handleJump(scope)">{{scope.name}}</span>
        </span>
      </s-table>
    </a-spin>
  </a-modal>
</template>

<script>
import pick from 'lodash.pick'
import { STable } from '@/components'
import { financeSumListStatistics } from '@/api/system'
// 表单字段
const fields = ['id']
const columns = [
  {
    title: '名称',
    dataIndex: 'name',
    key: 'name',
    scopedSlots: { customRender: 'name' },

  },
  {
    title: '金额',
    dataIndex: 'amount',
    key: 'amount',
  },
]


export default {
  props: {
    visible: {
      type: Boolean,
      required: true,
    },
    data: {
      type: Object,
      required: {},
    },
    jumpUrl: {
      type: String,
      default: null
    }
  },
  components:{
    STable,
  },
  data() {
    this.columns = columns
    return {
      form: this.$form.createForm(this),
      list: [],
      loading:false,
      statusMap:{
        1:{status: 'green', name: '通过'},
        2:{status: 'red', name: '驳回'}
      },
      typeMap:{
        1:{status: 'green', name: '初审'},
        2:{status: 'red', name: '终审'},
        3:{status: 'blue', name: '打款'},
      },
      parameter: {
        pageNum: 1,
        pageSize: 10,
      },
      queryParam: {
      },
      init:true,
      loadData: (parameter) => {
        this.loading = true
        const requestParameters = Object.assign({}, this.data, this.queryParam)
        // requestParameters.type = 1
        return financeSumListStatistics(requestParameters).then((res) => {
            this.init = false
          this.loading = false;
          let result = {
            data: res.data,
            pageNo: 1,
            pageSize: 10,
            totalCount: res.data.length,
            totalPage: 1,
          }
          return result
        })
      },
    }
  },
  created() {},
  methods: {
    handleJump(scope){
      this.$emit('jump', scope)
    }
  },
  watch: {
    visible: function (n, o) {
      if (n) {
        if(!this.init){
          this.$refs.table.refresh()
        }
      }
    },
  },
}

</script>
<style lang="less" scoped>
.jumpName{
  cursor: pointer;

}
</style>